#include<fcntl.h>
#include<unistd.h>
#include<stdio.h>
int main(){
    int fd;
    //以只读方式打开文件
    fd = open("test2.txt", O_RDONLY );
    if(fd < 0){
        perror("open");
        return -1;
    }

    char buff[64];
    int read_len = 0;
    int total = 0;
   while((read_len = read(fd,buff,64)) > 0) {
        total += read_len;
   }
   
   printf("total: %d\n", total);
    close(fd);
    return 0;
}